<!--
 * @description:
 * @author: cuicui
 * @Date: 2023-11-23 18:50:42
 * @LastEditTime: 2023-11-26 23:17:22
 * @LastEditors: cuicui
-->
<template>
  <a-config-provider :locale='locale'>
    <div id='app'>
      <router-view />
    </div>
  </a-config-provider>
</template>

<script>
import { domTitle, setDocumentTitle } from '@/utils/domUtil'
import { i18nRender } from '@/locales'
import { WS_CONECTION, WS_DATA, WS_SENDDATA } from '@/store/mutation-types'

const debounce = (fn, delay) => {
  let timer = null

  return function() {
    let context = this

    let args = arguments

    clearTimeout(timer)

    timer = setTimeout(function() {
      fn.apply(context, args)
    }, delay)
  }
}
// 解决 ResizeObserver报错问题
const _ResizeObserver = window.ResizeObserver

window.ResizeObserver = class ResizeObserver extends _ResizeObserver {
  constructor (callback) {
    callback = debounce(callback, 16)
    super(callback)
  }
}
export default {
  data () {
    return {}
  },
  computed: {
    locale () {
      // 只是为了切换语言时，更新标题
      const { title } = this.$route.meta
      title && (setDocumentTitle(`${i18nRender(title)} - ${domTitle}`))

      return this.$i18n.getLocaleMessage(this.$store.getters.lang).antLocale
    }
  },
  methods: {
  },
  mounted () {
    this.$store.dispatch(WS_CONECTION)
  },
  beforeDestroy () {
  }
}
</script>
